package com.example.admin.controller;

import com.example.admin.base.PageResponse;
import com.example.admin.base.ResponseResult;
import com.example.admin.bean.NursingPlan;
import com.example.admin.bean.NursingProject;
import com.example.admin.service.NursingPlanservice;
import com.example.admin.service.NursingProjectservice;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/nursingplan")

public class NursingPlancon {
    @Autowired
    NursingPlanservice NursingPlanservice;
    @GetMapping("list")

    public ResponseResult<Object> searchingforlist( @RequestParam(defaultValue = "1")Integer pagenum,
                                                 @RequestParam(defaultValue = "50") Integer pagesize,NursingPlan NursingPlan){
        PageResponse<NursingPlan> list = NursingPlanservice.searchingforlist(pagenum, pagesize, NursingPlan);
        return ResponseResult.success(list);
    }
    @PostMapping("/save")

    public ResponseResult save( @RequestBody NursingPlan NursingPlan) {
        NursingPlanservice.save(NursingPlan);

        return ResponseResult.success();
    }
    @GetMapping("/findbyid")

    public ResponseResult<NursingPlan> findbyid( Long id){
        NursingPlan NursingPlan = NursingPlanservice.findbyid(id);
        return ResponseResult.success(NursingPlan);
    }
    @PutMapping("/edit")

    public ResponseResult<Integer> edit(@RequestBody NursingPlan NursingPlan){
        System.out.println("我进来了edit");
        Integer num = NursingPlanservice.edit(NursingPlan);
        return ResponseResult.success(num);
    }
    @GetMapping("/fixstatus/{id}/{status}")

    public ResponseResult<Integer> fixstatus(@PathVariable("id")Long id,@PathVariable("status")Integer status){
       Integer successnum =  NursingPlanservice.fixstatus(id,status);
       return ResponseResult.success(successnum);
    }
    @DeleteMapping("/delete/{id}")

    public ResponseResult<Integer> delete(@PathVariable("id")Long id){
       Integer deletenum = NursingPlanservice.delete(id);
       return ResponseResult.success(deletenum);
    }
}
